package com.example.zk1

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.example.common.entity.BannerEntity
import com.example.common.mvvm.BaseViewModel
import kotlinx.coroutines.launch

class MainViewModel:BaseViewModel() {
    val success = MutableLiveData<BannerEntity>()
    val fail = MutableLiveData<String>()

    fun getBanner(){
        viewModelScope.launch {
            try {
                val result = apiServer.getBanner()
                success.value = result
            }catch (e:Exception){
                fail.value = e.message
            }
        }
    }
}